package com.yidu.hbats.service.Recovery;

import com.github.pagehelper.PageHelper;
import com.yidu.hbats.dao.AtsSchemeAuditMapper;
import com.yidu.hbats.model.AtsSchemeAudit;
import com.yidu.hbats.service.NutritionAtsScheme.NutritionAtsSchemeAuditService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @program: spring-boot-demo
 * @description: ${description}
 * @author: lr
 * @create: 2019-12-02 09:41
 */

@Service
public class RecoveryAtsSchemeAuditServiceImpl implements  RecoveryAtsSchemeAuditService{

    //审核表的dao
    @Resource
    AtsSchemeAuditMapper atsSchemeAuditMapper;

    /**
     * 新增
     * @param record
     * @return
     */
    @Override
    public int insertSelective(AtsSchemeAudit record) {
        Date utilDate = new Date();//util.Date
        java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
        record.setCreatTime(sqlDate);
        //默认传10正在审核
        record.setAuditState("10");
        //默认传1是有效
        record.setIsva(1);
        return atsSchemeAuditMapper.insertSelective(record);
    }

    /**
     *根据方案主键修改方法
     * @param atsSchemeAudit 一个对象
     * @return
     */
    @Override
    public int updateByPrimaryKeySelectivetwo(AtsSchemeAudit atsSchemeAudit) {
        return atsSchemeAuditMapper.updateByPrimaryKeySelectivetwo(atsSchemeAudit);
    }

    /**
     * 根据方案主键修改方法
     * @param atsSchemeAudit 一个对象
     * @return
     */
    @Override
    public int updateByPrimaryKeySelectivethree(AtsSchemeAudit atsSchemeAudit) {
        return atsSchemeAuditMapper.updateByPrimaryKeySelectivethree(atsSchemeAudit);
    }

    /**
     * 查询所有带分页
     * @param atsSchemeAudit
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public List<AtsSchemeAudit> selectByPrimaryKeyTwowx(AtsSchemeAudit atsSchemeAudit,Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        return atsSchemeAuditMapper.selectByPrimaryKeyTwowx(atsSchemeAudit);
    }

    /**
     * 查询总行数
     * @param atsSchemeAudit
     * @return
     */
    @Override
    public int selectByPrimaryKeyCountTwowx(AtsSchemeAudit atsSchemeAudit) {
        return atsSchemeAuditMapper.selectByPrimaryKeyCountTwowx(atsSchemeAudit);
    }

    /**
     * 根据id查询所有
     * @param schemeId 方案id
     * @return
     */
    @Override
    public AtsSchemeAudit selectBySchemeIdFour(int schemeId) {
        return atsSchemeAuditMapper.selectBySchemeIdFour(schemeId);
    }

    /**
     * 根据id查询所有
     * @param schemeId 方案id
     * @return
     */
    @Override
    public int selectByPrimaryKeyCountThree(int schemeId) {
        return atsSchemeAuditMapper.selectByPrimaryKeyCountThree(schemeId);
    }

    /**
     *
     * @param atsSchemeAudit 审核表
     * @return
     */
    @Override
    public int updateByPrimaryKeySelectiveFour(AtsSchemeAudit atsSchemeAudit) {
        return atsSchemeAuditMapper.updateByPrimaryKeySelectiveFour(atsSchemeAudit);
    }
}
